package cn.ekuma.epos.datalogic.define.dao.erp;

import java.util.List;

import cn.ekuma.data.dao.ViewDAO;

import com.openbravo.bean.erp.viewbean.PassengerFlowTransaction;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.QBFBuilder;
import com.openbravo.data.loader.SerializerWriteBasic;
import com.openbravo.data.loader.StaticSentence;

public class PassengerFlowTransactionDAO extends ViewDAO<PassengerFlowTransaction>{

    public PassengerFlowTransactionDAO(I_Session s) {
        super(s);
    }

    @Override
    public Class getSuportClass() {
        return PassengerFlowTransaction.class;
    }

    public PassengerFlowTransaction readValues(DataRead dr,PassengerFlowTransaction obj) throws BasicException {
    	if(obj==null)
    		obj=new PassengerFlowTransaction();
    	obj.setCurDate(dr.getTimestamp(1));
    	obj.setTotalPrice(dr.getDouble(2));
    	obj.setConsultCost(dr.getDouble(3));
        return obj;
    }

    @Override
    public List<PassengerFlowTransaction> list(Object filter) throws BasicException {
        return new StaticSentence(s, new QBFBuilder(
                "SELECT T.CURDATE,T.TOTALPRICE,TOTALCONSULTCOST  "
                + "FROM TICKETS T "
                + "LEFT OUTER JOIN LOCATIONS S ON T.LOCATIONREF=S.ID "
                + "WHERE ?(QBF_FILTER) "
                + "ORDER BY T.CURDATE DESC ", new String[]{ "T.CURDATE", "T.CURDATE", "T.CUSTOMER","T.HOSTNAME","S.NAME","T.TICKETTYPE"}), new SerializerWriteBasic(new Datas[]{Datas.OBJECT, Datas.TIMESTAMP, Datas.OBJECT, Datas.TIMESTAMP, Datas.OBJECT, Datas.STRING, Datas.OBJECT, Datas.STRING, Datas.OBJECT, Datas.STRING, Datas.OBJECT, Datas.INT}), this).list(filter);
    }
}
